package com.dayuanit.dy8.atm.springbootatm.controller;

import com.dayuanit.dy8.atm.springbootatm.captcha.GifCaptcha;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
public class CaptchaController extends BaseController {

    @RequestMapping("/getCaptcha")
    public void getCaptcha(HttpServletResponse response, HttpSession session) {

        GifCaptcha captcha = new GifCaptcha(146, 33, 5);
        try {
            captcha.out(response.getOutputStream());
            session.setAttribute("captcha", captcha.text());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
